using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TurnController : MonoSingleton<TurnController>
{
    public int turnCount;
    public bool isPlayerTurn;
    public bool isEnemyTurn;
    public bool isWaitForPlayer;
    public bool canEndPlayerTurn;
    public void StartTurn()//回合数从1开始
    {
        isPlayerTurn = false;
        isEnemyTurn = false;
        turnCount = 0;
        ToPlayerTurn();
    }

    public void ToPlayerTurn()
    {
        if(!isPlayerTurn)
        {
            turnCount++;
            isWaitForPlayer = true;
            canEndPlayerTurn = true;
            isPlayerTurn = true;
            FindObjectOfType<EndTurnBtn>().StartTurn();//Fixed
            Debug.Log("进入了玩家回合");
        }
        else
        {
            Debug.LogError("在player的回合进入了player的回合");
        }
    }

    public void LeavePlayerTurn()
    {
        if (isPlayerTurn)
        {
            isWaitForPlayer = false;
            isPlayerTurn = false;
            canEndPlayerTurn = false;
            Debug.Log("离开了玩家回合");
        }
        else
        {
            Debug.LogError("在enemy的回合离开了player的回合");
        }
    }

    public void ToEnemyTurn()
    {
        if (!isEnemyTurn)
        {
            isEnemyTurn = true;
            Debug.Log("进入了敌人回合");
        }
        else
        {
            Debug.LogError("在enemy的回合进入了enemy的回合");
        }
    }

    public void LeaveEnemyTurn()
    {
        if (isEnemyTurn)
        {
            isEnemyTurn = false;
            Debug.Log("离开了敌人回合");
        }
        else
        {
            Debug.LogError("在player的回合离开了enemy的回合");
        }
    }
}
